<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
var user = {
    name: "李三",
    age : "19",
    phoneNumber: "123123123",
    password: "22014124" // 不能让别人拿到
}
var proxy = new Proxy(user, {
    get: function(target, attribute, receiver) {
        if(attribute == "password"){
            return target.password.substring(0, target.password.length - 3) + "***"
        }else{
            return Reflect.get(target, attribute, receiver)
        }
    },
    set: function(target, attribute, value){
        if (attribute == "password")
            target[attribute] = "用户密码已修改   "
        else
            target[attribute] = value
        
    }
})
proxy.password = "123123asda" // 这是通过代理设置的
console.log(proxy.password)
Reflect.set(user, "password", "密码修改成功!")
console.log(Reflect.get(user, "password"))


    </script>
</body>
</html>